var oTableProducts;
var server_path_shop;
$(document).ready(function(){
	server_path_shop=$("#server_path").val();
	
	oTableProducts = $('#products').dataTable(  
	{
		"aoColumns": [
		{ "bSortable": true },
		{ "bSortable": true },
		{ "bSortable": true },
		{ "bSortable": true },
		{ "bSortable": true },
		{ "bSortable": true },
		{ "bSortable": true },
		{ "bSortable": true },
		{ "bSortable": true }
		] } 
		);


	
});
function check_company(field,product,check){
	if($(check).is(':checked')){
		val=1;
	}else{
		val=0;
	}
	sendData = 'field_update='+field+'&company='+product+'&value='+val;
	$.ajax({
		type: "POST",
		url: server_path_shop+"libs/companies_ajax.php",
		data: sendData,
		// dataType:'json',
		success: function(data){
			
		}
	});
}

function delete_product(company,obj){
	bootbox.confirm("Are you sure?", function(result) {
		sendData = 'delete_company='+product;
		$.ajax({
			type: "POST",
			url: server_path_shop+"libs/companies_ajax.php",
			data: sendData,
		// dataType:'json',
		success: function(data){
			row = $(obj).closest("tr").get(0);
			oTableProducts.fnDeleteRow(oTableProducts.fnGetPosition(row));
		}
	})
	});
}
function delete_selected(){
	var vals=''
	$('.delete_selected').each(function(index,value){
		if($(this).is(":checked")){
			vals+=$(this).val()+',';
		}	
	});
	bootbox.confirm("Are you sure?", function(result) {
		sendData = 'delete_selected='+vals;
		$.ajax({
			type: "POST",
			url: server_path_shop+"/wizard/libs/products_ajax.php",
			data: sendData,
		// dataType:'json',
		success: function(data){
			$('.delete_selected').each(function(index,value){
				if($(this).is(":checked")){
					row = $(this).closest("tr").get(0);
					oTableProducts.fnDeleteRow(oTableProducts.fnGetPosition(row));
				}
			});
		}
	})
	});
}
